﻿using Bettzueche.Dampfross;
using System;
using System.Diagnostics;
namespace Bettzueche.DampfrossContinuum
{
    /// <summary>
    /// 
    /// </summary>
    [DebuggerDisplay("KachelC({Content})")]
    [Serializable]
    public class KachelC : Hexagon<KachelCContent>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="KachelC"/> class.
        /// </summary>
        public KachelC() : base() {
            Content = new KachelCContent();
        }
    }

    /// <summary>
    /// Im kontinuierlichen Dampfross-Szenario besitzt eine Kachel lediglich einen Wert zwischen 0 und 1, um
    /// den Landschaftstyp zu beschreiben.
    /// </summary>
    /// <remarks>
    /// <code>
    /// E0 (ohne Fluss): [0.0 - 0.1[
    /// E1 (Fluss li.): [0.1 – 0.2[
    /// E2 (Fluss ztrm.): [0.2 – 0.3[
    /// E3 (Fluss li.+ztrm): [0.3 – 0.4[
    /// B0 (ohne Fluss): [0.4 - 0.5[
    /// B1 (Fluss li.): [0.5 – 0.6[
    /// B2 (Fluss ztrm.): [0.6 – 0.7[
    /// B3 (Fluss li.+ztrm): [0.7 – 0.8[
    /// W 	[0.8 – 0.9[
    /// unbekannt: [0.9 – oo[
    /// </code>
    /// </remarks>
    [Serializable]
    public class KachelCContent : KachelContent
    {
        /// <summary>
        /// Gibt oder setzt das Grundmaß für die Kacheleigenschaft / dass Landschaftsmerkmal.
        /// </summary>
        /// <value>
        /// The measure base. Should be in [0.0 , 0.1[
        /// </value>
        /// <remarks>
        /// Das Grundmaß ist ein Wert zwischen 0.0 (inkl.) und 0.1 (exkl.).
        /// Dieser Bereich entspricht einer Ebene. Ist der Kacheltyp <c>Berg</c>, erhöht sich
        /// der Wert um 0.4 und bei Wasser um 0.8.
        /// Das endgültige Bewertungsmaß ergibt sich erst in <c>UmgebungC</c> unter Berücksichtigung
        /// der Perspektive und FlussFlags.
        /// </remarks>
        internal double MeasureBase { get; set; }

        // Optionale Properties
        ///// <summary>
        ///// Gets a value indicating whether this Kachel is a water field.
        ///// </summary>
        ///// <value>
        /////   <c>true</c> if this instance is water; otherwise, <c>false</c>.
        ///// </value>
        //public bool IsWater { get { return MeasureBase >= 0.8 && MeasureBase < 0.9; } }

        ///// <summary>
        ///// Gets a value indicating whether this Kachel type is unknown.
        ///// </summary>
        ///// <value>
        ///// <c>true</c> if this instance is unknown; otherwise, <c>false</c>.
        ///// </value>
        //public bool IsUnknown { get { return MeasureBase >= 0.9; } }

        ///// <summary>
        ///// Gets a value indicating whether this Kachel type is water or unknown.
        ///// </summary>
        ///// <value>
        ///// <c>true</c> if this instance is water or unknown; otherwise, <c>false</c>.
        ///// </value>
        //public bool IsWaterOrUnknown { get { return MeasureBase >= 0.8; } }

        ///// <summary>
        ///// Gets a value indicating whether this Kachel is a mountain.
        ///// </summary>
        ///// <value>
        ///// <c>true</c> if this instance is mountain; otherwise, <c>false</c>.
        ///// </value>
        //public bool IsMountain { get { return MeasureBase >= 0.4 && MeasureBase < 0.8; } }

        /// <summary>
        /// Initializes a new instance of the <see cref="KachelCContent"/> class.
        /// </summary>
        /// <param name="measure">The measure, ein Maß für die Kacheleigenschaft / dass Landschaftsmerkmal.</param>
        public KachelCContent(double measure) :
            base()
        {
            MeasureBase = measure;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="KachelCContent"/> class.
        /// </summary>
        /// <param name="measure">The measure.</param>
        /// <param name="typ">The typ.</param>
        /// <param name="riverFlags">The river flags.</param>
        public KachelCContent(double measure, Kacheltyp typ, Rivers riverFlags) :
            base(typ, riverFlags)
        {
            MeasureBase = measure;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="KachelCContent"/> class.
        /// </summary>
        public KachelCContent() :
            base()
        {

        }

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public override int GetHashCode() {
            return base.GetHashCode() ^ MeasureBase.GetHashCode();
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj) {
            KachelCContent other = obj as KachelCContent;
            if (other == null) {
                return false;
            }
            else
                return Equals(other);
        }

        /// <summary>
        /// Equalses the specified other.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns></returns>
        public bool Equals(KachelCContent other) {
            if (!base.Equals(other)) {
                return false;
            }
            return this.MeasureBase == other.MeasureBase;
        }

        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString() {
            string retVal = String.Format("{0:N3} ", MeasureBase) + base.ToString();
            return retVal;
        }

        // user-defined conversion from or to base class not allowed
        ///// <summary>
        ///// Performs an explicit conversion from <see cref="KachelContent"/> to <see cref="KachelCContent"/>.
        ///// </summary>
        ///// <param name="diskrete">The diskrete.</param>
        ///// <returns>
        ///// The result of the conversion.
        ///// </returns>
        //public static explicit operator KachelCContent(KachelContent diskrete) {
        //    if (diskrete == null)
        //        return null;
        //    KachelCContent newContent = new KachelCContent(0.0, diskrete.Typ, diskrete.FlussFlags);
        //    return newContent;
        //}
    }
}
